package com.zy.Conterller;

import com.zy.pojo.Recycle;
import com.zy.service.DelService;
import com.zy.vo.ManagementVo;
import com.zy.vo.ResultVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/cus/recycle/")
public class DelController {
    @Resource
    private DelService delService;
  /*  @GetMapping("/list")
    @RequiresPermissions("del:list")
    public ResultVo getDelList(){
        return ResultVo.success( delService.getDelList());

    }*/
    @GetMapping("dellist/{pageSize}/{pageNo}")
    @RequiresPermissions("recycle:list")
    public ResultVo getPurList(@PathVariable Integer pageSize, @PathVariable Integer pageNo, ManagementVo managementVo){

            return ResultVo.success(delService.getPage(pageNo,pageSize,managementVo));


    }
    @PostMapping("add")
    @RequiresPermissions("recycle:add")
    public ResultVo getDelPerAdd(@RequestBody Recycle recycle){
        try{
        delService.getDelPurList(recycle);
        delService.del(recycle.getId());
        return ResultVo.success("还原数据成功");
        }catch (Exception e){
            return ResultVo.fail("还原数据失败",e);
        }
    }
/*    @GetMapping("del/{id}")
    @RequiresPermissions("delpur:delete")
   public ResultVo del(@PathVariable String id){
       try{
           delService.delete(Integer.parseInt(id));
           return ResultVo.success("采购合同删除成功");
       }catch (Exception e){
           return ResultVo.fail("采购合同删除失败");
       }
   }*/
   @GetMapping("ma/{id}")
   @RequiresPermissions("recycle:del")
   public ResultVo del(@PathVariable String id){
       try{
           delService.del(Integer.parseInt(id));
           return ResultVo.success("数据删除成功");
       }catch (Exception e){
           return ResultVo.fail("数据删除失败");
       }
   }
}
